package com.xukai.springboot.controller.article;

import com.xukai.springboot.entity.article.t_a_body;
import com.xukai.springboot.entity.article.t_a_main;
import com.xukai.springboot.entity.request.article.ArtileResquest;
import com.xukai.springboot.entity.request.article.DelArtileResquest;
import com.xukai.springboot.entity.response.PageResult;
import com.xukai.springboot.entity.response.ResponseBase;
import com.xukai.springboot.entity.response.article.ArtileResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@Api(basePath = "api/article", description = "文章管理")
@RestController
@RequestMapping("api/article/*")
public class ArticleController {

    /**
     * 日志
     */
    private final Logger logger = LoggerFactory.getLogger(ArticleController.class);

    /**
     * 获取文章列表
     */
    @ApiOperation(value = "获取文章列表", notes = "获取文章列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "StartIndex", value = "检索数据起始行", required = true, dataType = "int", example = "0", defaultValue = "0", paramType = "query"),
            @ApiImplicitParam(name = "PageSize", value = "检索数据大小", required = true, dataType = "int", example = "0", defaultValue = "0", paramType = "query"),
            @ApiImplicitParam(name = "TypeID", value = "文章分类ID", required = false, dataType = "int", example = "0", defaultValue = "0", paramType = "query"),
            @ApiImplicitParam(name = "ArticleName", value = "文章名称", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "Author", value = "文章作者", required = false, dataType = "string", paramType = "query")
    })
    @GetMapping("GetArticleList")
    public ResponseBase<PageResult<t_a_main>> GetArticleList(@RequestParam int StartIndex, @RequestParam int PageSize
            , @RequestParam int TypeID, @RequestParam String ArticleName, @RequestParam String Author) {
        ResponseBase<PageResult<t_a_main>> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("获取文章列表", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 新建文章
     */
    @ApiOperation(value = "新建文章", notes = "新建文章")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "文章内容", required = true, dataType = "ArtileResquest", paramType = "body")
    })
    @PostMapping("CreateArticle")
    public ResponseBase<ArtileResquest> CreateArticle(@RequestBody ArtileResquest Param) {

        ResponseBase<ArtileResquest> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("新建文章", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 获取文章详情
     */
    @ApiOperation(value = "获取文章详情", notes = "获取文章详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ArticleID", value = "文章ID", required = true, dataType = "ArtileResponse", paramType = "query")
    })
    @PostMapping("GetArticle")
    public ResponseBase<ArtileResponse> GetArticle(@RequestParam int ArticleID) {

        ResponseBase<ArtileResponse> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("获取文章详情", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 编辑文章信息
     */
    @ApiOperation(value = "编辑文章信息", notes = "编辑文章信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "文章内容", required = true, dataType = "ArtileResquest", paramType = "body")
    })
    @PostMapping("SaveArticle")
    public ResponseBase SaveArticle(@RequestBody ArtileResquest param) {
        ResponseBase<ArtileResponse> result = new ResponseBase<>();
        try {
        } catch (Exception e) {
            logger.error("编辑文章信息", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 删除文章信息
     */
    @ApiOperation(value = "删除文章信息", notes = "删除文章信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Param", value = "文章删除参数", required = true, dataType = "DelArtileResquest", paramType = "body")
    })
    @PostMapping("DelArtile")
    public ResponseBase DelArtile(@RequestBody DelArtileResquest Param) {
        ResponseBase result = new ResponseBase();
        try {
        } catch (Exception e) {
            logger.error("删除文章信息", e);
            result.setStatue(0);
        }
        return result;
    }

    /**
     * 获取文章内容
     *
     * @param ArtileID
     * @return
     */
    @ApiOperation(value = "获取文章内容", notes = "获取文章内容")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ArtileID", value = "文章ID", required = true, dataType = "string", paramType = "query")
    })
    @GetMapping("GetArtileBody")
    public ResponseBase<t_a_body> GetArtileBody(@RequestParam int ArtileID) {
        ResponseBase<t_a_body> result = new ResponseBase();
        try {
        } catch (Exception e) {
            logger.error("获取文章内容", e);
            result.setStatue(0);
        }
        return result;
    }

}
